import { axiosInstance } from '../axios'
import CommonConfig from '../../assets/js/config'
const reportUrl = CommonConfig.reportUrl
// 列举产品下拉框
function getSearchMaterials (searchKey) {
  const newUrl = `process/v1/products:searchKey`
  let reqData = {
    params: {
      searchKey
    }
  }
  return axiosInstance.get(newUrl, reqData).then((res) => {
    return Promise.resolve(res)
  })
}
// 订单号模糊搜索
function getSearchOrder (orderNumber) {
  const newUrl = `planning/v1/workshop_plannings/order_numbers:search`
  let reqData = {
    params: {
      orderNumber
    }
  }
  return axiosInstance.get(newUrl, reqData).then((res) => {
    return Promise.resolve(res)
  })
}

// 获取生产报表
function getProduceReports (params) {
  const newUrl = `${reportUrl}/v1/produce_reports`
  let reqData = {
    params
  }
  return axiosInstance.get(newUrl, reqData).then((res) => {
    return Promise.resolve(res)
  })
}
// 导出生产报表
function exportProduceReports (params) {
  const newUrl = `${reportUrl}/v1/produce_reports/excel:export`
  return axiosInstance.post(newUrl, params).then((res) => {
    return Promise.resolve(res)
  })
}
// 获取__自定义报表列表__根据单位
export function getReportingCompanyList (params) {
  const newUrl = `${reportUrl}/v1/list_custom_reporting`
  return axiosInstance.get(newUrl, params).then((res) => {
    return Promise.resolve(res)
  })
}

export default {
  getSearchMaterials,
  getSearchOrder,
  getProduceReports,
  exportProduceReports
}
